//
//  testsound.cpp
//  iBallance
//
//  Created by Apple on 12-5-15.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#include <iostream>
#include "SoundEngine.h"



void init()
{
    
    
    SoundEngine_Initialize(44100);
	
	SoundEngine_SetListenerPosition(0.0, 0.0, 0.0f);
	
	// keeps the file name
	char *filename = (char*)malloc(2048 * sizeof(char));
	memset(filename, 0, 2048 * sizeof(char));
    
	// keeps the path to the sound data
	char *buffer = (char*) malloc(2048 * sizeof(char));
	memset(buffer, 0, 2048 * sizeof(char));
	
	//GetResourcePathASCII(buffer, 2048);
	
	// Load each of the four sounds used here
	sprintf(filename, "%s/Start.caf", buffer);
	if(SoundEngine_LoadEffect(filename, &Sounds[kSound_Start]))
		printf("**ERROR** Failed to load sound file.\n");
	sprintf(filename, "%s/Success.caf", buffer);
	if(SoundEngine_LoadEffect(filename, &Sounds[kSound_Success]))
		printf("**ERROR** Failed to load sound file.\n");
	sprintf(filename, "%s/Failure.caf", buffer);
	if(SoundEngine_LoadEffect(filename, &Sounds[kSound_Failure]))
		printf("**ERROR** Failed to load sound file.\n");
	sprintf(filename, "%s/Thrust.caf", buffer);
	if(SoundEngine_LoadLoopingEffect(filename, NULL, NULL, &Sounds[kSound_Thrust]))
		printf("**ERROR** Failed to load sound file.\n");
	
	free(buffer);
	free(filename);  
	
	IsSoundRunning[kSound_Thrust] = true;
	SoundEngine_StartEffect( Sounds[kSound_Thrust]);

    
    
}